// Package sysin
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sysin

import (
	"context"
	"hotgo/internal/consts"
	"hotgo/internal/model/entity"
	"hotgo/internal/model/input/form"
	"hotgo/utility/validate"

	"github.com/gogf/gf/v2/errors/gerror"
	"github.com/gogf/gf/v2/frame/g"
)

// ProductCategoryUpdateFields 修改商品分类字段过滤
type ProductCategoryUpdateFields struct {
	Name   string `json:"name"   dc:"分类名称"`
	Sort   int    `json:"sort"   dc:"排序"`
	Status int    `json:"status" dc:"状态"`
	Remark string `json:"remark" dc:"备注"`
}

// ProductCategoryInsertFields 新增商品分类字段过滤
type ProductCategoryInsertFields struct {
	Name   string `json:"name"   dc:"分类名称"`
	Sort   int    `json:"sort"   dc:"排序"`
	Status int    `json:"status" dc:"状态"`
	Remark string `json:"remark" dc:"备注"`
}

// ProductCategoryEditInp 修改/新增商品分类
type ProductCategoryEditInp struct {
	entity.ProductCategory
}

func (in *ProductCategoryEditInp) Filter(ctx context.Context) (err error) {
	// 验证分类名称
	if err := g.Validator().Rules("required").Data(in.Name).Messages("分类名称不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证排序
	if err := g.Validator().Rules("required").Data(in.Sort).Messages("排序不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	return
}

type ProductCategoryEditModel struct{}

// ProductCategoryDeleteInp 删除商品分类
type ProductCategoryDeleteInp struct {
	Id interface{} `json:"id" v:"required#分类ID不能为空" dc:"分类ID"`
}

func (in *ProductCategoryDeleteInp) Filter(ctx context.Context) (err error) {
	return
}

type ProductCategoryDeleteModel struct{}

// ProductCategoryViewInp 获取指定商品分类信息
type ProductCategoryViewInp struct {
	Id int64 `json:"id" v:"required#分类ID不能为空" dc:"分类ID"`
}

func (in *ProductCategoryViewInp) Filter(ctx context.Context) (err error) {
	return
}

type ProductCategoryViewModel struct {
	entity.ProductCategory
}

// ProductCategoryListInp 获取商品分类列表
type ProductCategoryListInp struct {
	form.PageReq
	Id     int64  `json:"id"     dc:"分类ID"`
	Name   string `json:"name"   dc:"分类名称"`
	Status int    `json:"status" dc:"状态"`
}

func (in *ProductCategoryListInp) Filter(ctx context.Context) (err error) {
	return
}

type ProductCategoryListModel struct {
	Id     int64  `json:"id"     dc:"分类ID"`
	Name   string `json:"name"   dc:"分类名称"`
	Sort   int    `json:"sort"   dc:"排序"`
	Status int    `json:"status" dc:"状态"`
	Remark string `json:"remark" dc:"备注"`
}

// ProductCategoryMaxSortInp 获取商品分类最大排序
type ProductCategoryMaxSortInp struct{}

func (in *ProductCategoryMaxSortInp) Filter(ctx context.Context) (err error) {
	return
}

type ProductCategoryMaxSortModel struct {
	Sort int `json:"sort" description:"排序"`
}

// ProductCategoryStatusInp 更新商品分类状态
type ProductCategoryStatusInp struct {
	Id     int64 `json:"id" v:"required#分类ID不能为空" dc:"分类ID"`
	Status int   `json:"status" dc:"状态"`
}

func (in *ProductCategoryStatusInp) Filter(ctx context.Context) (err error) {
	if in.Id <= 0 {
		err = gerror.New("分类ID不能为空")
		return
	}

	if in.Status <= 0 {
		err = gerror.New("状态不能为空")
		return
	}

	if !validate.InSlice(consts.StatusSlice, in.Status) {
		err = gerror.New("状态不正确")
		return
	}
	return
}

type ProductCategoryStatusModel struct{}


